CDataUtils2.cs
Code Type: C# Class
Uses Classes: JavaScriptSerializer, Regex, CStatus, TripleDESCryptoServiceProvider, 3]


Lines of Code: 421

public static class CDataUtils2

	This class contains helper methods for conversion and formatting of values 

public static string GetEmptyJSON()

	get empty JSON 

public static string GetJsonRecordValue(string strName,
                                                string strJsonRecord)

	gets a value from a single json record by name, json is name/value pair 

static public DateTime GetMDWSShortDate(string strDateTime)

	 get MDWS date without time 

public static string SanitizeCommand(string str)

	 sanitizes a command string 

public static string SanitizeEncodedHTML(string strEncoded)

	 Sanitize encoded HTML 

public static string Sanitize(string str)

	 sanitize a string 

public static string DBSanitize(string str)

	used to sanitize values stored in the db 

public static string TruncateString(string strText, int nChars)

	 truncates the passed in string at the specifed length - 3 and adds an ellipsis 

static public string DelimitString(
            string strText,
            string strDelimiter,
            int nChars)

	 breaks a string up and inserts a delimeter 

static public int GetRowCount(DataSet ds)

	 helper to get the number of rows in a dataset 

static public DateTime GetNullDate()

	 We use 01/01/0001 to mean a "null" date. this will return a null date 

static public bool IsNumeric(string strValue)

	 is this string a numeric value? 

static public bool IsDateNull(DateTime dt)

	 We use 01/01/0001 to mean a "null" date. this will check to see if the date is null 

static public k_COMPARE CompareDates(DateTime dt1, DateTime dt2)

	 compare dates -1 = invalid 0 = equal 1 = dt1 > dt2 2 = dt2 > dt1 

static public k_COMPARE CompareDateTimes(DateTime dt1, DateTime dt2)

	 compare datetimes -1 = invalid 0 = equal 1 = dt1 > dt2 2 = dt2 > dt1 

static public DateTime GetMDWSDate(string strDateTime)

	 gets a date time given a MDWS date formatted 20030428.000700 

static public string GetMDWSShortDateString(DateTime dt)

	get a date in a MDWS format with time set to to 000000 

static public string GetMDWSShortDateString(DateTime dt, string strTime)

	get date as string formatted for MDWS 

static public string GetMDWSLongDateString(DateTime dt)

	get a full date time in MDWS format 

static public DateTime GetDate(
            string strDateTime,
            int nHH,
            int nMM,
            int nSS)

	 gets a date given a formmated datetime string mm/dd/yyyy and hh mm ss 

static public DateTime GetDate(string strDateTime)

	 gets a date given a formmated datetime string mm/dd/yyyy 

static public long ToLong(string strValue)

	 convert a string to a long 

static public long ToLong(k_ACTIVE activeValue)

	 converts a constant k_active to a long 

static public string GetMilitaryDateAsString(DateTime dt)

	 gets mil date as string YYYYMMDD 

static public string GetDateAsString(DateTime dt)

	 used to retrieve a date in a string format for display 

static public string GetDateTimeAsString(DateTime dt)

	 used to retrieve a date/time in a string format for display 

static public bool IsEmpty(DataSet ds)

	 helper to determine if a dataset is empty 

static public CStatus GetDSDelimitedData(
            DataSet ds,
            string strField,
            string strDelimeter,
            out string strData)

	  gets a dataset as delimeted fields 

static public long GetDSLongValue(DataSet ds, string strField)

	  helper to get one value from a dataset as a string 

static public double GetDSDoubleValue(DataSet ds, string strField)

	 helper to get a double value from a DS 

static public double GetDSDoubleValue(DataRow dr, string strField)

	 helper to get a double value from a data row 

static public DateTime GetDSDateTimeValue(DataSet ds, string strField)

	 helper to get a datetime value from a record 

static public long GetDSLongValue(DataRow dr, string strField)

	 helper to get a value from a dataset row as a long 

static public string GetDSStringValue(DataRow dr, string strField)

	 helper to get one value from a dataset as a string 

static public DateTime GetDSDateTimeValue(DataRow dr, string strField)

	 helper to get a datetime from a data row 

static public string GetDSStringValue(DataSet ds, string strField)

	 helper to get one value from a dataset as a string 

static public k_ACTIVE ToActiveID(string strValue)

	 converts a string to a contstant k_ACTIVE 

static public k_ACTIVE ToActiveID(int nValue)

	 converts an integer to a contstant k_ACTIVE 

static public k_ACTIVE ToActiveID(long lValue)

	 converts a long to a contstant k_ACTIVE 

static public string enc(
            string strClear,
            string strEKey,
            string strEInitVector)

	 triple des encrypt a string 

static public string dec(
            string strEnc,
            string strEKey,
            string strEInitVector)

	 triple des decrypt a string 

	

